package com.renjian.util;

import java.io.IOException;

import net.rim.device.api.i18n.ResourceBundle;
import net.rim.device.api.io.Base64OutputStream;
import net.rim.device.api.ui.Screen;

import com.renjian.model.KeyMap;

public class HackUtil implements Constant {
	public boolean isWifiEnabled = false;
	public String cookie = "";
	public boolean isCheckWifi = false;

	public String base64Encrypt(String target) throws IOException {

		return Base64OutputStream.encodeAsString(target.getBytes(), 0, target
				.length(), false, false);
	}

	public void checkWifi(ResourceBundle _resource, final Screen screen) {
		isCheckWifi = true;
		String url = _resource.getString(CHECKWIFI);
		KeyMap[] keyMap = new KeyMap[0];
		KeyMap[] paras = new KeyMap[0];
		try {
			new HttpConnectionUtil() {

				public boolean process(byte[] ch) {
					logger.log("wifi 's enabled.");
					isWifiEnabled = true;
					return true;
				}

			}.processRequest(url, paras, keyMap);
		} catch (IOException e) {
			logger.log("wifi 's disabled due to " + e.getMessage());
		}
		isCheckWifi = false;
	}
}
